<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>交通灯问题</title>
</head>

<body>
    123
    <script type="module">
        import { TrafficLight } from "./TrafficLight.js";

        const light = new TrafficLight({
            red: 3,
            yellow: 1,
            green: 2,
            initial: 'red', // 起始灯值
        })

        window.light = light;
        // const current = light.getCurrentLight();

        // 每隔16毫秒运行一次 即 浏览器的刷新频率
        function raf() {
            requestAnimationFrame(() => {
                raf()
                const current = light.getCurrentLight()
                console.log(current.color, current.remain);
            })
        }
        // raf()
    </script>
</body>

</html>